/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import domain.player.Player;
import gui.GUIController;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.*;
import java.util.Iterator;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.MatteBorder;

/**
 *
 * @author Mattis
 */
public class GameBoard extends JPanel {
    
    private GUIController guiController;
    private JLabel[][] board;
    
    public GameBoard() {
        setConfig();
        addSquares();
    }
    
    public GameBoard(GUIController guiController) {
        setConfig();
        addSquares();
        this.guiController = guiController;
    }

    private void setConfig() {
        this.setLayout(new GridLayout(3, 3));
        this.setBorder(new MatteBorder(1, 1, 1, 1, Color.BLACK));
        this.setSize(400, 400);
        this.setVisible(true);
        this.setOpaque(false);
        // this.setBackground(Color.red);
    }

    private void addSquares() {
        board = new JLabel[3][3];
        int x = 0;
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                board[i][j] = new JLabel("ruta" + i + j);
                board[i][j].setName(i + " " + j);
                board[i][j].addMouseListener(new MouseListener() {

                    @Override
                    public void mouseClicked(MouseEvent e) {
                        System.out.println("pressed");
                    }

                    @Override
                    public void mousePressed(MouseEvent e) {
                        throw new UnsupportedOperationException("Not supported yet.");
                    }

                    @Override
                    public void mouseReleased(MouseEvent e) {
                        throw new UnsupportedOperationException("Not supported yet.");
                    }

                    @Override
                    public void mouseEntered(MouseEvent e) {
                        throw new UnsupportedOperationException("Not supported yet.");
                    }

                    @Override
                    public void mouseExited(MouseEvent e) {
                        throw new UnsupportedOperationException("Not supported yet.");
                    }
                });

                this.add(board[i][j]);
            }
        }
        
        
    }
    
    public void resetGameBoard(){
        
    }
    
    public void presentWinnerBoard(Iterator iterator){
        
    }
    
    public JLabel[][] getGameBoard(){
        return this.board;
    }
}
